package servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import domain.Player;
import domain.Table;

public class PlayerServlet extends HttpServlet {
	@Override
	protected void doPost(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {

		String namePlayer = request.getParameter("name");
		int chipsPlayer = Integer.parseInt(request.getParameter("chips"));
		
		Table table = new Table();
		// se debe poder mostrar en el nro 19 la apuesta q hice ;P

		AuxTable auxTable = new AuxTable();
		
		Player player = new Player(namePlayer, chipsPlayer);
		table.addPlayer(player);
		
		request.getSession().setAttribute("rows", auxTable.getRows());
		request.getSession().setAttribute("player", player);
		request.getSession().setAttribute("table", table);
		request.getSession().setAttribute("aux", auxTable);
		request.getRequestDispatcher("table.jsp").forward(request, response);
	}
}
